/*
 * trace_CmdPathParam.c
 *
 *  Created on: 2012/07/12
 *      Author: guanxiaoying
 */

#include "../table.h"
#include "../trace_cmd_table.h"
typedef struct _CMDPATHPARAM
{
	AST astBlk;
	AST astChangingLog;
} CMDPATHPARAM, *PCMDPATHPARAM;

#define TableSize  (sizeof(CMDPATHPARAM ))
#define TableType  PCMDPATHPARAM
#define stTable stCmdPathParamManager.memoryBlocks
#define maxTable stCmdPathParamManager.maxRecordNum
#define  maxNumPerBlk  (stCmdPathParamManager.astMaxNum_Block)


static TABLEMANAGER stCmdPathParamManager = {
//		U4                  usIdx;
		0,
//		PSZ				    con_pszName;    constant
		__FILE__,
//		U2					con_usSize;		constant
		TableSize,
//		U2					block_num;	　　　　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_Block;     １回設定のみ
		0,
//		S4					astTabNum_LastPage; 　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_LastPage;     Reset clear  際　要
		0,
//		U4					ulMaxByte;	　　　　　　　　　　クリアしない
		0,
//		U4					con_minPageSize;　　　　　　　　　　constant
		0
};
static VOID resetListener( U4  procid, U2 index )
{
	if( procid == stCmdPathParamManager.u4Idx )
	{
		if( index > 0 && index < MAX_VOLUMN_OF_TABLE )
		{
			stTable[ index-1] = NULL;
		}
	}
}
static TableType core_getTable( AST index )
{
	TableType temp = (TableType)Check_Com( &stCmdPathParamManager, resetListener,  index );
	if( temp != NULL ){ return &temp[index%maxNumPerBlk]; } return NULL;
}
static BOOL ClearTable( VOID )
{
	return Clear_Com( &stCmdPathParamManager );
}
static BOOL AllocTable( AST astReqArg )
{
	return AllocTable_Com( &stCmdPathParamManager, astReqArg, resetListener );
}
static AST getMaxLineNum( VOID ){
	return maxTable;
}
static AST getVarBlock( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astBlk;
}
static AST setVarBlock( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astBlk=value;
}
static AST getLog( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astChangingLog;
}
static AST setLog( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astChangingLog=value;
}
const CMDPATHPARAMACCESS stCmdPathParamAccess={
		ClearTable,
		AllocTable,
		getMaxLineNum,
//		ACCESS_U2_FIELD condition;
//		ACCESS_IDX_FIELD beginNode;
//		ACCESS_IDX_FIELD endNode;
//		ACCESS_IDX_FIELD pathOut;
//		ACCESS_IDX_FIELD pathIn;
//		ACCESS_IDX_FIELD pathOut_next;
//		ACCESS_IDX_FIELD pathIn_next;
		{
				getVarBlock,
				setVarBlock
		},
		{
				getLog,
				setLog
		}
};

